#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/3/8 17:25
# @Author  : jeff
# @FileName: middleware_aspect
from loguru import logger


def middleware(app):
    @app.before_request
    def before_request():

        logger.info('Called before each request is routed')

    @app.before_request
    def after_request():
        logger.info('Called after each request has been routed')

    @app.teardown_request
    def teardown_request(exception):
        logger.info('Called after each request is processed')

    @app.teardown_appcontext
    def shutdown_session(exception=None):
        logger.info('Called when each request context is destroyed')